/**
 * @param {string} version1
 * @param {string} version2
 * @return {number}
 */
var compareVersion = function (version1, version2) {
  let arr1 = version1.split('.'), arr2 = version2.split('.')
  let i = 0, j = 0
  while (i < arr1.length && j < arr2.length) {
    if(parseInt(arr1[i])<parseInt(arr2[j])){
      return -1
    }else if(parseInt(arr1[i])>parseInt(arr2[j])){
      return 1
    }else {
      i++
      j++
    }
  }
  if(i==arr1.length && j==arr2.length) return 0
  if(i<arr1.length){
    while(i<arr1.length){
      if(parseInt(arr1[i])!=0) return 1
      else i++
    }
    return 0
  }
  if(j<arr2.length){
    while(j<arr2.length){
      if(parseInt(arr2[j])!=0) return -1
      else j++
    }

    return 0
  }
};